<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateWechatReplyTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('wechat_reply', [
            'comment' => '自动回复',
            'engine' => 'InnoDB', 
            'collation' => 'utf8mb4_general_ci'
        ]);
        $table->addColumn(Column::enum('group', ['keywords', 'subscribe', 'default'])->setComment('类型:keywords=关键字回复,subscribe=关注回复,default=默认回复'))
            ->addColumn(Column::enum('type', ['text', 'link', 'video', 'voice', 'image', 'news'])->setNull(true)->setDefault(null)->setComment('类型:text=文本,link=链接,video=视频,audio=音频,image=图像,media=图文消息'))
            ->addColumn(Column::enum('status', ['enable', 'disabled'])->setComment('状态:enable=启用,disabled=禁用'))
            ->addColumn('keywords', 'string', ['limit'  =>  255, 'null' => true, 'default' => null, 'comment' => '关键字'])
            ->addColumn('content', 'text', ['null' => true, 'default' => null, 'comment' => '回复内容'])
            ->addColumn('create_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '创建时间'])
            ->addColumn('update_time', 'integer', ['limit'  => 10, 'null' => true, 'default' => null, 'comment' => '更新时间'])
            ->addColumn('delete_time', 'integer', ['limit'  =>  10, 'null' => true, 'default' => null, 'comment' => '删除时间'])
            ->create();
    }


    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('wechat_reply');
        $table->drop();
    }
}
